import { $get, $put, $post } from '@js/request'
import { PDFSignSchema } from '@src/components/schema/pdf'
import { CaseSchema } from '@components/schema/caseSchema';
import { ArbitratorSchema } from '@src/components/schema/arbitrator';
import { ParticipantSchema } from '@src/components/schema/videoCourt';

export async function getDocumentRequest (caseid: string, id: string) {
  const res = await $get(`/api/commission/document/${caseid}/${id}`)
  return res.data
}

export async function getSignListRequest (documentid: string): Promise<PDFSignSchema[]> {
  const res = await $get(`/api/commission/documentca`, { documentid })
  return res.data
}

export async function updateSignRequest (v: { [k: string]: any }) {
  const id = v.id
  delete v.id
  const res = await $put(`/api/commission/documentca/${id}`, v)
  return res.data
}

export async function getCaseDataRequest (id: string): Promise<CaseSchema> {
  const res = await $get(`/api/commission/case/${id}`)
  return res.data
}

export async function getArbitratorsRequest (caseid: string): Promise<ArbitratorSchema[]> {
  const res = await $get(`/api/commission/case/${caseid}/arbitrator`)
  return res.data
}

export async function getParticipantListRequest (caseid: string): Promise<ParticipantSchema[]> {
  const res = await $get('/api/commission/participant', {
    caseid
  })
  return res.data
}

export async function reproductRequest (fileid: string) {
  const res = await $post('/api/commission/document/regenerate_file', {
    id: fileid
  })
  return res.data
}

export async function sendSignRequest (documentid: string) {
  const res = await $put('/api/commission/document/sendseal', { documentid })
  return res.data
}

export async function finishSignRequest (id: string) {
  const res = await $put(`/api/commission/document/accomplishSign/${id}`)
  return res.data
}